package com.guo.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.guo.cmn.mapper.DictMapper;
import com.guo.model.cmn.Dict;
import com.guo.vo.cmn.DictEeVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;

/**
 * @author gfj
 * @Date 2022/1/19 18:36
 */
@Slf4j
public class DictListener extends AnalysisEventListener<DictEeVo> {
	private DictMapper dictMapper;

	public DictListener(DictMapper dictMapper) {
		this.dictMapper = dictMapper;
	}

	@Override
	public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
		Dict dict = new Dict();
		BeanUtils.copyProperties(dictEeVo,dict);
		log.info("导入数据dict：{}",dict.toString());
		//int insert = dictMapper.insert(dict);//将上传的数据存入数据库
	}

	@Override
	public void doAfterAllAnalysed(AnalysisContext analysisContext) {
		log.info("完成数据的导入");
	}
}
